import os
from time import sleep
from bs4 import BeautifulSoup
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.wait import WebDriverWait
from awtools.log import log
from selenium import webdriver
import re

"""

"""

class lanjiyin(object):

    phone = '手机'
    pasword = '123456'

    def __new__(cls, url):
        log('这里是开始运行  new ')
        o = object.__new__(cls)
        return o

    def __init__(self, url, phone = None, pasword = None):
        if  phone != None:
            self.phone = phone
        if  pasword != None:
            self.pasword = pasword

        self.driver = webdriver.Chrome()
        self.driver.get(url=url)
        self.driver.maximize_window()
        self.base = ActionChains(self.driver)

        try:
            html = self.driver.page_source
            bObj = BeautifulSoup(html, features='html.parser')
            aObj = bObj.find('div', {'class':'about_left'})
            log.file_put_content('./aa.html', aObj.__str__())
            self.closes()
        except Exception as e:
            print(e)





    def isElement(self, cssSelect):
        try:
            btn = self.driver.find_element('css selector', cssSelect)
            return btn
        except Exception as e:
            return False







    def sleep1(self):
        sleep(0.5);

    def closes(self):
        log.debug('正在关闭浏览器')
        sleep(3)
        # self.driver.close()
        self.driver.quit()




o = lanjiyin('http://www.lanjiyin.com.cn')










